<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>	
<%@page import="com.yaodian100.mall.member.util.UserData"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 	

<c-rt:set var="ss" value='<%=System.currentTimeMillis()%>'/>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.cascade.ext.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.cascade.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.templating.js"></script>
<script language="javascript">
//Tina update
$().ready(function(){
	$("#dialog").dialog({
		bgiframe: true,
		height: 200,
		width:700,
		modal: true
	});
	$("#submitDialog").click(function(){
			$("input[type=radio]").each(function(){
				if(this.checked){
					var abId=$(this).attr("id");
					if(abId != ''){
						$.getJSON("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/findAddBook.do?type=json&ss=${ss}", 
								{abid:abId,adbk:"Y"}
							,function(addBookDataJson){
								$("#contactName").val(addBookDataJson.contactName).css("color","#000");
								$("#addr").val(addBookDataJson.addr).css("color","#000");
								$("#zipCode").val(addBookDataJson.zipCode);								
								if(addBookDataJson.mobile==null){
									$("#mobile").val("");
								}else{
									$("#mobile").val(addBookDataJson.mobile);
								}
								if(addBookDataJson.areaCode==null){
									$("#areaCode").val("");
								}else{
									$("#areaCode").val(addBookDataJson.areaCode);
								}
								if(addBookDataJson.phone==null){
									$("#phone").val("");
								}else{
									$("#phone").val(addBookDataJson.phone);
								}
								if(addBookDataJson.extension==null){
									$("#extension").val("");
								}else{
									$("#extension").val(addBookDataJson.extension);
								}
								
								$("#province").children().each(function(){
									if (trim($(this).text()) == trim(addBookDataJson.province)){
										$(this).attr("selected","true"); 
										queryProvince2(addBookDataJson.city,addBookDataJson.district);
										initCoupon();
										initBonus();
										initWallet();
										initGiftCard();
								}
								});
								
								//判断是否可货到付款
								var tmpCity=$("#city").find('option:selected').val();
								var tmpDistrict=$("#district").find('option:selected').text();
								if(tmpDistrict.substring(0,1)=='※'){
									$("#paytype30").attr("disabled",false); 
								}else{
									$("#paytype30").attr("disabled",true); 
									$("#paytype30").attr("checked",false);
								}								
								//计算运费
								var tmpProvince=$("#province").find('option:selected').val();
								var tmpIsBuyNow=$("#isBuyNow").val();
								var tmpFinalMustPay=$("#editTotalAmount").val();
								var addCmpPd=$("#addCmpPd").val();
								var buyNowCartId=$("#buyNowCartId").val();
								$.post("<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/getFreight.do?ss=${ss}",{codProvince:tmpProvince,isBuyNow:tmpIsBuyNow,finalMustPay:tmpFinalMustPay,addCmpPd:addCmpPd,buyNowCartId:buyNowCartId},callback,"json");
								function callback(result){
									$("#spanFreight").text(result);
									$("#editShipFare").val(parseFloat(result).toFixed(1));
									ProcessCalcuTotal();
								}		
						});
					}
				}
			});			
		closeDialog();
	});
});


</script>
<s:form action="<%=ServerValue.getFrontContextPath()%>/shopping/orderInfo/orderInfo.do" method="post" id="orderInfo">
 <DIV id="dialog" title="收货地址簿">
  <div class="f-rt txt-rd">*仅显示该商品能配送到达的地址</div>
  <span>请选择收货人：</span>
	<table width="100%" border="0" class="tb-2">
  <tr>
    <th width="5%"></th>
    <th width="15%">收货人</th>
    <th width="50%">地址</th>
    <th width="15%">手机号码</th>
    <th width="15%">固定电话</th>
  </tr>
   <c-rt:forEach items="${abList}" var="addbook" varStatus="rows_index"> 
   		<tr>${row_index.count }
        <td><input type="radio" name="abid" id="${addbook.id}" value="${addbook.id}"/></td>
	    <td>${addbook.contactName}</td>
	    <td>${addbook.province},${addbook.city},${addbook.district},${addbook.addr} ,${addbook.zipCode}</td>
	    <td>${addbook.mobile}</td>
	    <td>${addbook.areaCode}${addbook.phone} ${addbook.extension}</td>
	    </tr>
   </c-rt:forEach>
  
</table>
<p class="c-f"  align="center"><br /><a id="submitDialog" href="javascript:;" class="btn-mid" onFocus="blur()">确定</a></p>
  </DIV>
 </s:form>